package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.dto.DeviceDataDto;
import com.zzyl.nursing.dto.FamilyMemberDto;
import com.zzyl.nursing.dto.HealthDataDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    /**
     * 绑定家人
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FamilyMemberDto dto){
        familyMemberService.add(dto);
        return success();
    }

    /**
     * 查询家人列表
     * @return
     * */
    @GetMapping("/my")
    @ApiOperation("value = \"查询家人列表\"")
    public AjaxResult myFamilyMembers(){
        List<FamilyMemberVo> familyMemberList = familyMemberService.myFamilyMembers();
    return AjaxResult.success(familyMemberList);
    }
    /**
     * 分页查询家人列表
     */
    @GetMapping("/list-by-page")
    public AjaxResult list(Integer pageNum,Integer pageSize) {
        List<DeviceInfoVo> familyMemberList = familyMemberService.list(pageNum, pageSize);
        return success(familyMemberList);
    }
    @GetMapping("queryServiceProperties/{iotId}")
    public AjaxResult queryServiceProperties(@PathVariable String iotId) {
        List<DeviceDataVo> deviceDataVos =familyMemberService.queryServiceProperties(iotId);
        return success(deviceDataVos);
    }
    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(DeviceDataDto dto) {
        List<DataVO> list = familyMemberService.queryDeviceDataListByDay(dto);
        return success(list);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(DeviceDataDto dto) {
        List<DataVO> list = familyMemberService.queryDeviceDataListByWeek(dto);
        return success(list);
    }
}
